/**
 * Created by perqin on 16-12-6.
 */

'use strict';

/**
 * Module dependencies
 */
var mongoose = require('mongoose'),
  Schema = mongoose.Schema;

/**
 * Photo Schema
 */
var PhotoSchema = new Schema({
  // Schema field declaration
  _id: {
    type: Schema.ObjectId,
    auto: true
  },
  created: {
    type: Date,
    default: Date.now
  },
  in_story: {
    type: Schema.Types.ObjectId,
    ref: 'Story'
  },
  owned_by: {
    type: Schema.Types.ObjectId,
    ref: 'User'
  },
  thumbnail_size: {
    type: Number
  },
  thumbnail_url: {
    type: String
  },
  preview_size: {
    type: Number
  },
  preview_url: {
    type: String
  },
  origin_size: {
    type: Number
  },
  origin_url: {
    type: String
  }
}, {
  // Schema options
  toObject: {
    getters: true
  }
});

PhotoSchema.virtual('pid').get(function () {
  return this._id;
});

mongoose.model('Photo', PhotoSchema);
